package com.zjweu.hkg.Controller;

import com.zjweu.hkg.POJO.ChatHistory;
import com.zjweu.hkg.Servies.ChatHistoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@CrossOrigin
@RequestMapping("/chat")
public class ChatHistoryController {
    @Autowired
    ChatHistoryService chatHistoryService;

    /**
     * 添加AI聊天记录
     * @param chatHistory
     * @return
     */
    @PostMapping("/setChatHis")
    public int setChatHis(@RequestBody ChatHistory chatHistory){
        return  chatHistoryService.setChatHis(chatHistory);

    }

    /**
     * 根据UID获取聊天记录
     * @param chatHistory
     * @return
     */
    @PostMapping("/getChatHisByUID")
    public List<ChatHistory> getChatHisByUID(@RequestBody ChatHistory chatHistory){
        return chatHistoryService.getChatHisByUID(chatHistory.getUserId());
    }
}
